package com.elink.enginerring.common;

/**
 * 错误类型,0为正常处理返回,1**为客户端错误,2**为服务器错误(具体错误自定义,如101为请求参数错误)
 * @author hxjxiaojun
 * 
 */
public enum ErrorType{
	SUCCESS						                                        	(0, "success"),
	CLIENT_ERROR				                                         	 (1, "客户端未知错误"),
	SERVER_ERROR					                                         (2, "服务器未知错误"),
	NEED_LOGIN						                                         (-1, "请重新登录"),
	
	REQUEST_PARAMS_ERROR		                             	 (101, "请求参数不合法"),
	AUTHORITY_ERROR                                                   (102, "没有操作权限"),
	SESSION_TIMEOUT_ERROR		                                 (103, "session已超时"),
	REQUESTED_DATA_NOT_EXIST_ERROR	                     (104, "请求的数据不存在"),
	FILE_COMMENT_ERROR                                              (105, "您所评论的文件不存在"),
	COMMENT_REPLY_ERROR                                           (106, "您所回复的评论不存在"),
	COMMENT_PRAISE_ERROR                                          (107, "您所点赞的回复不存在"),
	FILE_DOWNLOAD_ERROR                                           (108,"您所下载的文件不存在"),
	REWARD_ERROR                                                        (109,"您的积分余额不足以下载该文件，请充值"),
	PRAISE_ERROR                                                           (110, "请不要重复"),
	COLLECTION_SUCCESS                                               (111, "收藏成功"),
	CANCEL_COLLECTION                                                (112, "您已取消收藏"),
	FILE_TYPE_ERROR			                                             (113, "暂时不支持该文件格式"),
	UPDATE_ERROR                                                         (114,"您无权修改该回复"),
	REPLY_ERROR                                                            (115,"该问题已存在最佳回复"),
	POSTBAR_REPLY_ERROR                                            (116,"对不起，同一个问题同一个用户只能够回复一次"),	
	CANCLE_PRAISE                                                         (117,"你已取消顶/踩"),	
	
	DATABASE_ERROR                                                    (201, "数据库操作出错"),
	HANDLE_FILE_ERROR			                                      (203, "服务器处理文件出错");
	

	
	
	private int code;
	private String msg;

	public int getCode() {
		return code;
	}

	public String getMsg() {
		return msg;
	}

	private ErrorType(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}
	/**
	 * 根据code获取到msg
	 * @param code
	 * @return
	 */
	public static String getMsgByCode(int code){
		for(ErrorType e:ErrorType.values()){
			if(e.getCode()==code){
				return e.getMsg();
			}
		}
		return null;
	}
}